﻿using LineOfBusiness.Core.Model;
using LineOfBusiness.DataAccess;
using LineOfBusiness.Poco.Custom;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using LineOfBusiness.Poco;

namespace LineOfBusiness.Helper
{
    public class DataUtilities
    {
        public IQueryable<SR_ItemModels> GetModels(EFDALContainer _EFDALContainer,DataServiceModel oDSM)
        {
            string SONo=oDSM.DataValue[0] as string;
            var model = from i in _EFDALContainer.Repository.GetQuery<IV_tblItemLists>()
                        join j in _EFDALContainer.Repository.GetQuery<SR_tblSalesOrdersLines>() on i.ItemID equals j.ItemID
                        where j.SONo == SONo
                        select new SR_ItemModels
                        {
                            ItemID = i.ItemID,
                            ItemName = i.ItemName,
                            M2D = string.IsNullOrEmpty(i.ModelID2D) ? false : true,
                            M3D = string.IsNullOrEmpty(i.ModelID3D) ? false : true,
                            Mold = string.IsNullOrEmpty(i.Mold) ? false : true
                        };
            return model.Distinct().AsQueryable();
        }
    }
}